﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace KWR.DAL
{
    public static class DataAccess
    {
        public static DataTable GetChaos()
        {
            DataTable dt = new DataTable("Kwrs");

            dt.Columns.Add("name");

            dt.Rows.Add(new object[] { "Game I" });
            dt.Rows.Add(new object[] { "Game II" });
            dt.Rows.Add(new object[] { "Game III" });
            dt.Rows.Add(new object[] { "Game IV" });
            dt.Rows.Add(new object[] { "Game V" });
            dt.Rows.Add(new object[] { "Game VI" });
            dt.Rows.Add(new object[] { "Game VII" });
            dt.Rows.Add(new object[] { "Game VIII" });
            dt.Rows.Add(new object[] { "Game IX" });

            return dt;
        }

        public static DataTable GetAllChaosTransformations(string kwrName)
        {
            DataTable dt = new DataTable("Kwrs");

            dt.Columns.Add("a");
            dt.Columns.Add("b");
            dt.Columns.Add("c");
            dt.Columns.Add("d");
            dt.Columns.Add("e");
            dt.Columns.Add("f");

            switch (kwrName)
            {
                case "Game I":
                    {
                        dt.Rows.Add(new object[] { 0.5000, 0.0000, 0.0000, 0.5000, 0.0000, 0.0000 });
                        dt.Rows.Add(new object[] { 0.5000, 0.0000, 0.0000, 0.5000, 0.5000, 0.0000 });
                        dt.Rows.Add(new object[] { 0.5000, 0.0000, 0.0000, 0.5000, 0.2500, 0.5000 });
                        break;
                    }
                case "Game II":
                    {
                        dt.Rows.Add(new object[] { 0.5000, 0.0000, 0.0000, 0.5000, 0.0000, 0.0000 });
                        dt.Rows.Add(new object[] { 0.5000, 0.0000, 0.0000, 0.5000, 0.5000, 0.0000 });
                        dt.Rows.Add(new object[] { 0.5000, 0.0000, 0.0000, 0.5000, 0.2500, 0.5000 });
                        break;
                    }
                case "Game III":
                    {
                        dt.Rows.Add(new object[] { 0.0000, 0.0000, 0.0000, 0.1600, 0.0000, 0.0000 });
                        dt.Rows.Add(new object[] { 0.2000, -0.2300, 0.0000, 0.2200, 0.0000, 1.6000 });
                        dt.Rows.Add(new object[] { -0.1500, 0.2800, 0.2600, 0.2400, 0.0000, 0.4400 });
                        dt.Rows.Add(new object[] { 0.8500, 0.0400, -0.0400, 0.8500, 0.0000, 1.6000 });
                        break;
                    }
                case "Game IV":
                    {
                        dt.Rows.Add(new object[] { 0.000, 0.0000, 0.0000, 0.1600, 0.0000, 0.0000 });
                        dt.Rows.Add(new object[] { 0.2000, -0.2300, 0.0000, 0.2200, 0.0000, 1.6000 });
                        dt.Rows.Add(new object[] { -0.1500, 0.2800, 0.2600, 0.2400, 0.0000, 0.4400 });
                        dt.Rows.Add(new object[] { 0.8500, 0.0400, -0.0400, 0.8500, 0.0000, 1.6000 });
                        break;
                    }
                case "Game V":
                    {
                        dt.Rows.Add(new object[] { 0.0000, 0.0000, 0.0000, 0.2500, 0.0000, -0.4000 });
                        dt.Rows.Add(new object[] { 0.0350, -0.2000, 0.1600, 0.0400, -0.0900, 0.0200 });
                        dt.Rows.Add(new object[] { -0.0400, 0.2000, 0.1600, 0.0400, 0.0830, 0.1200 });
                        dt.Rows.Add(new object[] { 0.9500, 0.0050, -0.0050, 0.9300, -0.0020, 0.5000 });
                        break;
                    }
                case "Game VI":
                    {
                        dt.Rows.Add(new object[] { 0.1950, -0.4880, 0.3440, 0.4430, 0.4431, 0.2452 });
                        dt.Rows.Add(new object[] { 0.4620, 0.4140, -0.2520, 0.3610, 0.2511, 0.5692 });
                        dt.Rows.Add(new object[] { -0.0580, -0.0700, 0.4530, -0.1110, 0.5976, 0.0969 });
                        dt.Rows.Add(new object[] { -0.0350, 0.0700, -0.4690, -0.0220, 0.4884, 0.5069 });
                        dt.Rows.Add(new object[] { -0.6370, 0.0000, 0.0000, 0.5010, 0.8662, 0.2513 });
                        break;
                    }
                case "Game VII":
                    {
                        dt.Rows.Add(new object[] { 0.0000, 0.5770, -0.5770, 0.0000, 0.0951, 0.5893 });
                        dt.Rows.Add(new object[] { 0.0000, 0.5770, -0.5770, 0.0000, 0.4413, 0.7893 });
                        dt.Rows.Add(new object[] { 0.0000, 0.5770, -0.5770, 0.0000, 0.0952, 0.9893 });
                        break;
                    }
                case "Game VIII":
                    {
                        dt.Rows.Add(new object[] { 0.3330, 0.0000, 0.0000, 0.3330, 0.0000, 0.0000 });
                        dt.Rows.Add(new object[] { 0.1670, -0.2890, 0.2890, 0.1670, 0.3330, 0.0000 });
                        dt.Rows.Add(new object[] { 0.1670, 0.2890, -0.2890, 0.1670, 0.5000, 0.2890 });
                        dt.Rows.Add(new object[] { 0.3330, 0.0000, 0.0000, 0.3330, 0.6670, 0.0000 });
                        break;
                    }
                case "Game IX":
                    {
                        dt.Rows.Add(new object[] { 0.3333, 0.0000, 0.0000, 0.3333, 0.0000, 0.6666 });
                        dt.Rows.Add(new object[] { 0.3333, 0.0000, 0.0000, 0.3333, 0.0000, 0.3333 });
                        dt.Rows.Add(new object[] { 0.3333, 0.0000, 0.0000, 0.3333, 0.0000, 0.0000 });
                        dt.Rows.Add(new object[] { 0.3333, 0.0000, 0.0000, 0.3333, 0.3333, 0.0000 });
                        dt.Rows.Add(new object[] { 0.3333, 0.0000, 0.0000, 0.3333, 0.6666, 0.0000 });
                        dt.Rows.Add(new object[] { 0.3333, 0.0000, 0.0000, 0.3333, 0.3333, 0.6666 });
                        dt.Rows.Add(new object[] { 0.3333, 0.0000, 0.0000, 0.3333, 0.6666, 0.6666 });
                        dt.Rows.Add(new object[] { 0.3333, 0.0000, 0.0000, 0.3333, 0.6666, 0.3333 });
                        break;
                    }
                default:
                    break;
            }

            return dt;
        }


        public static DataTable GetChaosProbability(string kwrName)
        {
            DataTable dt = new DataTable("Kwrs");

            dt.Columns.Add("p");
            dt.Columns.Add("id");

            switch (kwrName)
            {
                case "Game I":
                    {
                        dt.Rows.Add(new object[] { 0.3333, 1 });
                        dt.Rows.Add(new object[] { 0.3333, 2 });
                        dt.Rows.Add(new object[] { 0.3333, 3 });
                        break;
                    }
                case "Game II":
                    {
                        dt.Rows.Add(new object[] { 0.1, 1 });
                        dt.Rows.Add(new object[] { 0.3, 2 });
                        dt.Rows.Add(new object[] { 0.6, 3 });
                        break;
                    }
                case "Game III":
                    {
                        // Wariant "wszyscy po równo"
                        dt.Rows.Add(new object[] { 0.25, 1 });
                        dt.Rows.Add(new object[] { 0.25, 2 });
                        dt.Rows.Add(new object[] { 0.25, 3 });
                        dt.Rows.Add(new object[] { 0.25, 4 });
                        break;
                    }
                case "Game IV":
                    {
                        // Warian "sprawiedliwy"
                        //dt.Rows.Add(new object[] { 0.01128, 1 });
                        //dt.Rows.Add(new object[] { 0.04961, 3 });
                        //dt.Rows.Add(new object[] { 0.12267, 4 });
                        //dt.Rows.Add(new object[] { 0.81644, 2 });

                        // wariant bez "nieroba"
                        dt.Rows.Add(new object[] { 0.0, 1 });
                        dt.Rows.Add(new object[] { 0.050176759, 3 });
                        dt.Rows.Add(new object[] { 0.124073441, 4 });
                        dt.Rows.Add(new object[] { 0.8257498, 2 });
                        
                        break;
                    }
                case "Game V":
                    {
                        dt.Rows.Add(new object[] { 0.02, 1 });
                        dt.Rows.Add(new object[] { 0.07, 2 });
                        dt.Rows.Add(new object[] { 0.07, 3 });
                        dt.Rows.Add(new object[] { 0.84, 4 });
                        break;
                    }
                case "Game VI":
                    {
                        dt.Rows.Add(new object[] { 0.2, 1 });
                        dt.Rows.Add(new object[] { 0.2, 2 });
                        dt.Rows.Add(new object[] { 0.2, 3 });
                        dt.Rows.Add(new object[] { 0.2, 4 });
                        dt.Rows.Add(new object[] { 0.2, 5 });
                        break;
                    }
                case "Game VII":
                    {
                        dt.Rows.Add(new object[] { 0.3333, 1 });
                        dt.Rows.Add(new object[] { 0.3333, 2 });
                        dt.Rows.Add(new object[] { 0.3333, 3 });
                        break;
                    }
                case "Game VIII":
                    {
                        dt.Rows.Add(new object[] { 0.25, 1 });
                        dt.Rows.Add(new object[] { 0.25, 2 });
                        dt.Rows.Add(new object[] { 0.25, 3 });
                        dt.Rows.Add(new object[] { 0.25, 4 });
                        break;
                    }
                case "Game IX":
                    {
                        dt.Rows.Add(new object[] { 0.125, 1 });
                        dt.Rows.Add(new object[] { 0.125, 2 });
                        dt.Rows.Add(new object[] { 0.125, 3 });
                        dt.Rows.Add(new object[] { 0.125, 4 });
                        dt.Rows.Add(new object[] { 0.125, 5 });
                        dt.Rows.Add(new object[] { 0.125, 6 });
                        dt.Rows.Add(new object[] { 0.125, 7 });
                        dt.Rows.Add(new object[] { 0.125, 8 });
                        break;
                    }
                default:
                    break;
            }

            return dt;
        }


    }
}
